﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Uncle : RelationBase
    {
        private static Uncle _singleton = new Uncle();
        public static Uncle Instance
        {
            get { return _singleton; }
        }

        private Uncle() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's uncle IFF b is male AND one of a's parents is b's sibling
            return (b.Sex == Sex.Male &&
                (b.KnownRelation(Sibling.Instance, a.Mother) ||
                b.KnownRelation(Sibling.Instance, a.Father)));
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Sibling.Instance, Mother.Instance, Father.Instance });
        }
    }
}
